<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>公共字段</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <script src="/style/public/publicStyle.js"></script>
</head>

<body>
<div class="weadmin-body">
    <div class="layui-row">
        <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
    </div>
</div>

<div class="layui-row" id="detail" style="display:none;">
    <table class="layui-hide" id="detailTable" lay-filter="detailTable"></table>
</div>
</body>

<script>
layui.use(['table','layer'],function () {
    var util = layui.util
        , laypage = layui.laypage //分页
        , layer = layui.layer //弹层
        , table = layui.table //表格、
        , form = layui.form;
    table.render({
        elem: '#mainTable'
        , even: false //开启隔行背景
        , cellMinWidth: 80
        , toolbar: '#toolbarDemo'
        , defaultToolbar: []
        , url: '/med/mdMedTblog/findByPage'
        , where: {
            //filter: $("#tableFilter").val()
        }
        , cols: [[
            , {field: 'idTblog', hide:true}
            , {field: 'naTp',title:'描述'}
            , {field: 'cdTb',title:'表名'}
            , {field: 'euStatus',title:'状态',templet: function(data) {
                    var d = data.euStatus;
                    if (d == 0) {
                        return '失败'
                    } else if (d == 1) {
                        return '成功'
                    }
                }}
            , {field: 'dtSysCre',title:'创建时时间',templet : "<div>{{layui.util.toDateString(d.dtSysCre, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
            , {field: 'naUseCre',title:'创建人'}
            , {fixed: 'right', title: '操作', align: 'center', toolbar: '#op'}
        ]]
        , page: true
        ,done: function (res,curr,count) {

        }
    });
    table.render({
        elem: '#detailTable'
        , even: false //开启隔行背景
        , defaultToolbar: []
        , url: ''
        , data:[]
        , cols: [[
            , {field: 'idTblogDt', hide:true}
            , {field: 'title',title:'描述',width:200}
            , {field: 'euStatus',title:'状态',width:80,templet: function(data) {
                    var d = data.euStatus;
                    if (d == 0) {
                        return '失败'
                    } else if (d == 1) {
                        return '成功'
                    }
                }}
            , {field: 'sqlExec',title:'sql'}
            , {field: 'des',title:'备注',width:300}
        ]]
        , page: false
    });
    table.on('tool()', function (obj) {
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值
        if (layEvent == 'detail') {
            $.ajax({
                type: "get",
                url: "/med/mdMedTblog/findDetail",
                async: true,
                data: {'idTblog': data.idTblog},
                success: function (d) {
                    layer.open({
                        //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                        type: 1,
                        title:"明细" ,
                        area: ['920px', '600px'],
                        content: $("#detail")//引用的弹出层的页面层的方式加载修改界面表单
                    });
                    table.reload("detailTable",{data:d.data});
                }
            });

        } else if (layEvent == 'delete') {
            layer.confirm('确定删除' + data.na + '指标吗？', {
                btn: ['继续', '取消'], //按钮
            }, function () {
                layer.closeAll('dialog');
                $.ajax({
                    type: "get",
                    url: "/med/mdIndex/delete",
                    async: true,
                    data: {'idIndex': data.idIndex},
                    success: function (json) {
                        table.reload("mainTable",{where:{filter: $("#tableFilter").val()}});
                    }
                });
            });
        }
    });
});
</script>
<!--表格操作-->
<script type="text/html" id="op">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="exec">执行</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="detail">详情</a>
</script>